<template>
  <div>
    <el-button type="primary" @click="willadd"> 添加</el-button>
    <!-- 表格 -->
    <!-- 点击边编辑出现弹框 -->
    <!-- 将list传递给list组件渲染数据 -->
    <v-list @willdeit="willedit"></v-list>
    <!-- 父传子让弹框消失 -->
    <v-form :info="info"  ref="form"></v-form>
  </div>
  <!-- <v-list></v-list> -->
</template>
<script>
import vList from '../goods/components/vList.vue'
import vForm from '../goods/components/vForm.vue';
import { mapGetters, mapActions } from "vuex";


export default {
  props: [],
  components: {
    vList,
    vForm,
 
  },
  data() {
    return {
      // 为了让子组件能直接修改父组件的isshow所以传递的时候用对象赋值

      // isshow:false,
      // 对象info赋值的时候给的是地址
      info: {
        isshow: false,
        isadd: true,
      },
      // list: [],
    };
  },
  computed: {
    ...mapGetters,
  },
  methods: {
    ...mapActions,

    
    // 点击添加this.isshow真
    //添加按钮
    willadd() {
      this.info.isshow = true;
      this.info.isadd = true;
    },
    // 点击编辑
    willedit(id) {
      this.info.isshow = true;
      this.info.isadd = false;
          // 调用子组件 .getone(id)方法完成修改
     this.$refs.form.getone(id)
 
    },

  },
  mounted() {
 
  },
};
</script>
 <style lang="less" scoped>
@import "../../less/index.less";
.el-button {
  margin-bottom: @margin;
}
</style>
